﻿
using OpenCvSharp;

using Xc.DataAccess.CodeReader.Properties;
using Xc.DataAccess.Core;

namespace Xc.DataAccess.CodeReader.Models.Filters
{
    /// <summary>
    /// 阈值
    /// </summary>
    [Filter("自适应阈值", FilterType.Algorithm)]
    public class AlgorithmAdaptiveThreshold : FilterBase
    {
        /// <summary>
        /// 最大值
        /// </summary>
        [InputParameter("最大值")]
        public double MaxValue { get; set; }
        /// <summary>
        /// 块大小
        /// </summary>
        [InputParameter("块大小")]
        public int BlockSize { get; set; }
        /// <summary>
        /// 常数值
        /// </summary>
        [InputParameter("常数值")] 
        public double C { get; set; }
        /// <summary>
        /// 类型
        /// </summary>
        [InputParameter("类型")]
        public ThresholdTypes ThresholdTypes { get; set; }
        [InputParameter("自适应阈值类型")]
        public AdaptiveThresholdTypes AdaptiveThresholdTypes { get; set; }
        internal override ResultData<Mat> UseChannel(Mat mat, FilterBase[] filterInfos, FilterBase preFilterBase)
        {
            Cv2.AdaptiveThreshold(mat, mat,  MaxValue, AdaptiveThresholdTypes, ThresholdTypes, BlockSize,C);
            return ResultData<Mat>.Accept(TextResource.filter_action_complete, mat);
        }
    }
}
